package com.kaige.usercenter.enums;

import lombok.Getter;

@Getter
public enum ErrorCodeEnum {
    PARAMS_ERROR(40000, "请求参数错误"),
    ACCOUNT_PWD_NOT_EXIST(40001, "用户不存在或密码错误"),
    ACCOUNT_ALREADY_EXIST(40002, "账号已存在"),
    ACCOUNT_NOT_EXIST(40003, "账号不存在"),
    ACCOUNT_PWD_INCORRECT(40004, "用户名或密码错误"),
    ACCOUNT_LOGIN_STATE(40005, "未登录"),
    ;
    private final int code;
    private final String message;
    private ErrorCodeEnum(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public static ErrorCodeEnum getEnumByCode(int code) {
        for (ErrorCodeEnum errorCodeEnum : ErrorCodeEnum.values()) {
            if (errorCodeEnum.code == code) {
                return errorCodeEnum;
            }
        }
        return null;
    }
}
